//菜单加载方法
//从本地存储获取此次登录用户信息
var userlocc = GetUser("userl");
addModuleMenu();
function addModuleMenu() {
  for (var i = 0; i < userModule.length; i++) {
    if (i == 0) {
      $(".left-menu").append(`<li class="layui-nav-item">
        <a href="javascript:;">${userModule[i].title}</a>
        <dl class="layui-nav-child bar">
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar1}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar2}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar3}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar4}</a></dd>
        </dl>
      </li>`);
    }
    if (i == 1) {
      $(".left-menu").append(`<li class="layui-nav-item">
        <a href="javascript:;">${userModule[i].title}</a>
        <dl class="layui-nav-child bar">
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar1}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar2}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar3}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar4}</a></dd>
        </dl>
      </li>`);
    }
    if (i == 2 && userlocc.grade != 1) {
      $(".left-menu").append(`<li class="layui-nav-item">
        <a href="javascript:;">${userModule[i].title}</a>
        <dl class="layui-nav-child bar">
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar1}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar2}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar3}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar4}</a></dd>
        </dl>
      </li>`);
    }
    if (i == 3) {
      $(".left-menu").append(`<li class="layui-nav-item">
        <a href="javascript:;">${userModule[i].title}</a>
        <dl class="layui-nav-child bar">
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar1}</a></dd>
          <dd><a class="lay-1" href="javascript:;">${userModule[i].bar2}</a></dd>
        </dl>
      </li>`);
    }
  }
}
$(".left-menu").append(`<li class="layui-nav-item ">
        <a onclick="tuic();" href="javascript:;">退出</a>
      </li>`);
//设置左菜单高度适配

var winheight = window.screen.height; //浏览器窗口
var Leftmenu = document.getElementById("left-menu");
Leftmenu.style.height = winheight - 60 + "px"; //设置高度
//退出清除本地数据
function tuic() {
  location.href = "./login.html";
  localStorage.removeItem("userl");
  localStorage.removeItem("userType");
  localStorage.removeItem("goodspj");
  localStorage.removeItem("storeguanli");
  localStorage.removeItem("management");
}
//工作台页面
$("#right-content").load("./html/gongzuotai.html");
//左菜单点击选择
$(".left-menu").on("click", ".lay-1", function () {
  console.log(this);
  let menuchoose = this.innerHTML;
  switch (menuchoose) {
    case "商品管理":
      $("#right-content").html("");
      $.ajax({ cache: false });
      $("#right-content").load("./html/storeguanli.html");
      break;
    case "品牌管理":
      $.ajax({ cache: false });
      $("#right-content").load("./html/management.html");
      break;
    case "类型管理":
      $.ajax({ cache: false });
      $("#right-content").load("./html/type_page.html");
      break;
    case "商品评价":
      $.ajax({ cache: false });
      $("#right-content").load("./html/goodspj.html");
      break;
    case "订单管理":
      $.ajax({ cache: false });
      $("#right-content").load("./html/orderManagement.html");
      break;
    case "退货/退款订单":
      $.ajax({ cache: false });
      $("#right-content").load("./html/tuihuoorder.html");
      break;
    case "管理员":
      $("#right-content").load("./html/yunying-guanli.html");
      break;
    case "角色管理":
      $.ajax({ cache: false });
      $("#right-content").load("./html/yunying-juese.html");
      break;
    case "广告版位":
      $.ajax({ cache: false });
      $("#right-content").load("./html/yunying-ggbw.html");
      break;
    case "广告管理":
      $.ajax({ cache: false });
      $("#right-content").load("./html/yunying-gggl.html");
      break;
    case "用户管理":
      $.ajax({ cache: false });
      $("#right-content").load("./html/user1.html");
      break;
    case "用户等级":
      $.ajax({ cache: false });
      $("#right-content").load("./html/user2.html");
      break;
    case "打印快递单":
      $.ajax({ cache: false });
      $("#right-content").load("./html/DaYinKuaiDiDan.html");
      break;
    case "发货信息管理":
      $.ajax({ cache: false });
      $("#right-content").load("./html/FaHuoXinXiGuanLi.html");
      break;
    // case "退出":
    //   $.ajax({ cache: false });
    //   function outputss() {
    //     console.log(1);
    //     windo.location.href = "./login.html";
    //   }
    // $(".out").click(function () {
    //   console.log(1);
    //   windo.location.href = "./login.html";
    // });

    // break;
    default:
      break;
  }
});
